package com.schoolvisitors.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum InstrumentType {
    RESEARCH_LAB(1L, "科研仪器"),
    TEACHING_LAB(2L, "教学仪器"),
    GENERAL_LAB(3L, "通用仪器"),
    SPECIALIZED_LAB(4L, "专用仪器");

    private final Long code;
    private final String name;

    InstrumentType(Long code, String name) {
        this.code = code;
        this.name = name;
    }

    // 根据code获取name的方法
    public static String getNameByCode(Long code) {
        for (InstrumentType type : values()) {
            if (Objects.equals(type.code, code)) {
                return type.name;
            }
        }
        return null; // 或者抛异常，根据需求
    }

    // 根据code获取枚举实例
    public static InstrumentType getByCode(Long code) {
        for (InstrumentType type : values()) {
            if (Objects.equals(type.code, code)) {
                return type;
            }
        }
        return null;
    }
}
